package com.payment.system.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.payment.common.base.AjaxResult;
import com.payment.common.constant.UserConstants;
import com.payment.common.support.Convert;
import com.payment.common.utils.StringUtils;
import com.payment.system.domain.ResourcesType;
import com.payment.system.mapper.ResourcesTypeMapper;
import com.payment.system.service.IResourcesTypeService;

/**
 * 资源类型 服务层实现
 * 
 * @author payment
 * @date 2019-01-24
 */
@Service
public class ResourcesTypeServiceImpl implements IResourcesTypeService 
{
	@Autowired
	private ResourcesTypeMapper resourcesTypeMapper;

	/**
     * 查询资源类型信息
     * 
     * @param id 资源类型ID
     * @return 资源类型信息
     */
    @Override
	public ResourcesType selectResourcesTypeById(Long id)
	{
	    return resourcesTypeMapper.selectResourcesTypeById(id);
	}



	/**
     * 查询资源类型列表
     * 
     * @param resourcesType 资源类型信息
     * @return 资源类型集合
     */
	@Override
	public List<ResourcesType> selectResourcesTypeList(ResourcesType resourcesType)
	{
	    return resourcesTypeMapper.selectResourcesTypeList(resourcesType);
	}
	
    /**
     * 新增资源类型
     * 
     * @param resourcesType 资源类型信息
     * @return 结果
     */
	@Override
	public int insertResourcesType(ResourcesType resourcesType)
	{
	    return resourcesTypeMapper.insertResourcesType(resourcesType);
	}
	
	/**
     * 修改资源类型
     * 
     * @param resourcesType 资源类型信息
     * @return 结果
     */
	@Override
	public int updateResourcesType(ResourcesType resourcesType)
	{
	    return resourcesTypeMapper.updateResourcesType(resourcesType);
	}

	/**
     * 删除资源类型对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteResourcesTypeByIds(String ids)
	{
		return resourcesTypeMapper.deleteResourcesTypeByIds(Convert.toStrArray(ids));
	}

	@Override
	public String checkTypeUnique(ResourcesType resourcesType) {
		Long dictId = StringUtils.isNull(resourcesType.getId()) ? -1L : resourcesType.getId();
		ResourcesType dictType = resourcesTypeMapper.checkTypeUnique(resourcesType.getType());
		if (StringUtils.isNotNull(dictType) && dictType.getId().longValue() != dictId.longValue())
		{
			return UserConstants.DICT_TYPE_NOT_UNIQUE;
		}
		return UserConstants.DICT_TYPE_UNIQUE;
	}

	@Override
	public   List<ResourcesType> selectResourcesTypeAll() {

		return resourcesTypeMapper.selectResourcesTypeAll();
	}

	@Override
	public AjaxResult selectResourcesTypeAllByXT() {
		List<ResourcesType> list=resourcesTypeMapper.selectResourcesTypeAllByXT();
		return AjaxResult.successAndData("获取资源信息成功",list);

	}


}
